<template>
	<view class="ysgudong">
		<view class="container">
			<gdlist :list="list"></gdlist>
			<u-loadmore :status="status" />
		</view>
	</view>
</template>

<script>
export default {
	name: 'ysgudong',
	data() {
		return {
			status: '',
			info: {},
			list: [],
			paging: {
				page: 1,
				pagenum: 10
			}
		};
	},
	onLoad() {
		this.reset();
		this.init();
	},
	onReachBottom() {
		if (this.status === 'nomore') return;
		this.init();
	},
	methods: {
		reset() {
			this.paging.page = 1;
			this.list = [];
		},
		init() {
			this.$http.getJson('users_stockers', { ...this.paging }).then((res) => {
				const { code, data, message } = res;
				if (code === 1) {
					if (data.length !== 0) this.list = this.list.concat(data);
					if (this.paging.pagenum === data.length) {
						this.paging.page += 1;
						this.status = 'loadmore';
					} else {
						this.status = 'nomore';
					}
				}
			});
		}
	}
};
</script>

<style lang="less" scoped>
.ysgudong {
	.container {
		padding: 24rpx 32rpx;
	}
}
</style>
